<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.io.*,java.util.*,java.text.*" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script>
function fnGetSubjects(a){
	var b = a.options[a.selectedIndex].value;
	var sub = document.enrollPage.action + '?semester=' + b; // use whatever url you want to.   
	//alert(sub);  
	//document.myForm.action = sub;
	document.enrollPage.submit();
	//alert("abt to go");
	//document.enrollPage.Enroll();
}

/*function doValidation() {
	var semester=document.getElementById("semester").value;
	alert("semester is:");
	alert(semester);
	if (semester==""){
		alert("Enter Semester for enrollment");
		return false;
	}
	else{	
		var subject=document.getElementById("subject").value;
		if (subject==""){
			alert("Select subject for enrollment");
			return false;
		}
	
	return true;
}*/
</script>
<title>Insert title here</title>
</head>
<body>
<h3><s:property value="msg"/> </h3>
<s:form name="enrollPage" action="StudentEnrollment" >
<table>
<tr>
<th>
<s:select label="Semester" name="semester" id="semester" list="semesterList" headerKey="" headerValue="Select" required="true" onChange="fnGetSubjects(this)"/>
<!--s:doubleselect label="Semester (OGNL) " name="semester" list="semesterList" doubleName="subject" doubleList="top == 'fall2012' ? {'apple', 'orange','banana'} : {'chicken', 'pig'}" /-->
<!--s:select label="Subject"  name="subject"  id="subject"  list="allCourseValues" listValue="name" multiple="true" size="3"  required="true"/-->
<% String sem=request.getParameter("semester");
	if(sem != null){
%>
</th>
<th>
<s:checkboxlist label="Subject" name="subject" id="subject" list="subjectList" required="true">
</s:checkboxlist>
<s:checkboxlist  name="enrSubject" id="enrSubject" list="enrolledList" value="enrolledList" disabled="true"/>
<%
}
%>
</th>
</tr>
</table>
<br>
<br>
<!-- s:set name="subList" value="subjectList"/-->
<!-- s:if test="%{#subList.length != 0}" -->
<s:submit name="commandButton" value="Enroll" id = "mysubmit" style="height: 30px; width: 200px" onclick="return doValidation()">
</s:submit>
<!-- /s:if -->
</s:form>
</body>
</html>